package Queue;


public class ListQueue {
    private ListNodeString head;
    private ListNodeString tail;

    public ListQueue() {
    }

    public boolean enqueue(String item){
        ListNodeString one = new ListNodeString(item);
        if(head==null){
            this.head = one;
            this.tail=one;
        }else{
            tail.next=one;
            tail=one;
        }
        return true;
    }
    public String dequeue(){
        if(head==null){
            return null;
        }
        String val = head.val;
        if(head.hashNext()){
            head=head.next;
        }else{
            head=null;
            tail=null;
        }
        return val;
    }

    public static void main(String[] args) {
        ListQueue queue = new ListQueue();
        queue.enqueue("Xxx");
        String dequeue = queue.dequeue();
        System.out.println(dequeue);
        dequeue = queue.dequeue();
        System.out.println(dequeue);
    }
}
